package com.norteksoft.erm.model;

import org.apache.commons.lang.builder.HashCodeBuilder;

/**
 * 数据域许可
 * 
 * @hibernate.class table="ERM_DATAPERMISSION"
 * @author Jiffy
 * 
 */
public class DataPermission extends BaseObject {

	public static final String ACCESS_GRANTED = "1";// 授予

	public static final String ACCESS_ABSTAIN = "0";// 弃权

	public static final String ACCESS_DENIED = "x";// 拒绝

	public static final String AUTHORITY_TYPE_GROUP = "GROUP";

	public static final String AUTHORITY_TYPE_ROLE = "ROLE";

	public static final String AUTHORITY_TYPE_USER = "USER";

	private Long OID = new Long(-1);// OID

	private String authorityType;// 权限授予对象类型

	private String authorityCode;// 权限授予对象编号（冗余）

	private String authorityName;// 权限授予对象名称（冗余）

	private Long authorityOID;// 功能授予对象OID（冗余）

	private String[] authzMode ;

	private DataDomain dataDomain;// 所属数据域

	public int hashCode() {
		return new HashCodeBuilder().append(OID).append(authorityType).append(
				authorityCode).append(authorityName).append(authorityOID)
				.append(authzMode).toHashCode();
	}

	/**
	 * @hibernate.id column="OID" unsaved-value="-1" type="long"
	 * @hibernate.generator class="sequence"
	 * @hibernate.param name="sequence" value="ERM_SEQUENCE_FREQUENT"
	 */
	public Long getOID() {
		return OID;
	}

	public void setOID(Long oid) {
		OID = oid;
	}

	/**
	 * @hibernate.property column="AUTHORITYCODE" length="60" type="string"
	 *                     not-null="true"
	 * @return String
	 */

	public String getAuthorityCode() {
		return authorityCode;
	}

	public void setAuthorityCode(String authorityCode) {
		this.authorityCode = authorityCode;
	}

	/**
	 * @hibernate.property column="AUTHORITYTYPE" length="30" type="string"
	 *                     not-null="true"
	 * @return String
	 */
	public String getAuthorityType() {
		return authorityType;
	}

	public void setAuthorityType(String authorityType) {
		this.authorityType = authorityType;
	}

	/**
	 * @hibernate.property column="AUTHZMODE" length="32"
	 *                     type="com.norteksoft.erm.model.hibernate.usertype.AuthzMode"
	 * @return String
	 */
	public String[] getAuthzMode() {
		return authzMode;
	}

	public void setAuthzMode(String[] authzMode) {
		this.authzMode = authzMode;
	}

	/**
	 * @hibernate.many-to-one name="dataDomain" column="DATADOMAINOID"
	 *                        class="com.norteksoft.erm.model.DataDomain"
	 */
	public DataDomain getDataDomain() {
		return dataDomain;
	}

	public void setDataDomain(DataDomain dataDomain) {
		this.dataDomain = dataDomain;
	}

	/**
	 * @hibernate.property column="AUTHORITYNAME" length="60" type="string"
	 *                     not-null="true"
	 * @return String
	 */
	public String getAuthorityName() {
		return authorityName;
	}

	public void setAuthorityName(String authorityName) {
		this.authorityName = authorityName;
	}

	/**
	 * @hibernate.property column="AUTHORITYOID" type="long"
	 */

	public Long getAuthorityOID() {
		return authorityOID;
	}

	public void setAuthorityOID(Long authorityOID) {
		this.authorityOID = authorityOID;
	}

	public String getAuthority() {
		return authorityType + "_" + authorityCode;
	}

}